Constant bit folding and propagation

ABSTRACT

A technique for constant bit folding, implemented by a compiler, logically processes only operand bits to generate bit sets useful for simplifying expressions. Bit sets indicating constant bits and constant bit values of the operands are generated and then logically processed to generate bit sets indicating constant bits and constant bit values of the results. Additionally, a bit set indicating operand bits that do not influence the result are generated.

CROSS-REFERENCES TO RELATED APPLICATIONS

[0001] This application claims priority from U.S. patent Application Ser. No. 09/506,408, filed Feb. 17, 2000, the disclosure of which is incorporated herein by reference in its entirety for all purposes.

BACKGROUND OF THE INVENTION

[0002] Constant-expression evaluation, or constant folding, refers to the evaluation at compile time of expressions whose values are known to be constant. In its simplest form, constant expression evaluation involves determining that all the operands in an expression are constant-valued, performing the evaluation of the expression at compile time, and replacing the expression by its value. For an integer, it is almost always applicable—the exceptions are cases that would produce run-time exceptions if they were executed, such as divisions by zero and overflows in languages whose semantics require overflow detection. A constant propagation method will propagate constant values throughout a program code, stimulate other constant foldings and other algebraic and peephole simplifications.

[0003] Generally, the following steps performed by a compiler to implement constant folding and expression simplification will include parsing the code to identify expressions. Then, the identified expressions are processed to evaluate constants and simplify the expressions. Finally, the simplified expressions are evaluated at run-time.

[0004] For the most part, constant folding is a complex technique and research continues to develop more efficient techniques.

SUMMARY OF THE INVENTION

[0005] According to one aspect of the invention, a method of analysis useful for delicate constant folding and for delicate transformation of arithmetic expressions considers the result of any expression as a set of independent bits at compile time. The method is used in optimizing compilers for computer platforms with supplementary coding.

[0006] According to another aspect of the invention, four sets can be determined by processing only the operands for any expression having integer operands and an integer result:

[0007] 1. The first set is a set of bits indicating which bits in the result are known to be constant, denoted the result-constant bit set (M).

[0008] 2. The second set is a set of values for the constant bits in the result, denoted the result-value bit set (C). This set indicates the values, i.e., 0 or 1, of the constant values in the result-constant bit set.

[0009] 3. The third set is a set of non-influence bits for each operand, indicating which bits of the operand do not influence the value of the result. This set is denoted the operand non-influence set (N_(x) for operand x).

[0010] 4. The fourth set is the intersection of the non-influence bit sets of each operand indicating the bit positions in the operands that have no influence on the result and thus are not required to be processed. This set is denoted the non-influence intersection set (N).

[0011] According to another aspect of the invention, the bit sets are stored in computer memory for further processing to evaluate and simplify expressions.

[0012] According to another aspect of the invention, a result-constant bit set is obtained by performing logical operations on operand-constant bit sets and operand-value bit sets, and a result-value bit set is obtained by performing logical operations on operand-constant bit sets, operand-value bit sets, and a result-constant bit set.

[0013] According to another aspect of the invention, the method calculates values of any format, for example (8, 16, 32, 64, . . . bits). The expressions of this method may also include non-algebraic operations with structure result.

[0014] According to another aspect of the invention, the method propagates the four sets corresponding to an expression throughout the program in which the expression occurs. This method thus enables use of the four sets to evaluate the equivalence of further constant folding transformations.

[0015] According to another aspect of the invention, on a computer platform with supplementary coding detailed formulas are provided for constant folding, for logic operations {˜, |, &, ^ }, arithmetic operations {+, −, *}, shift operations, some floating operations, and for analogs to those operations with cc flags.

[0016] According to another aspect of the invention, formulas are also provided for various combinations of those operations, which include also a set of simplifications. For example, formulas can be provided for {+, −, *, <<, >>, >>>} operations using only result-constant bit sets and result-value bit sets.

[0017] Other advantages and features of the invention will be apparent in view of the following detailed description and appended drawings.

BRIEF DESCRIPTION OF THE DRAWINGS

[0018]FIG. 1 is a flow chart depicting the steps of a preferred embodiment for generating and storing bit sets used for constant folding.

[0019]FIG. 2 is a schematic diagram depicting the values of x, y, M_(x), M_(y), C_(x), C_(y), M and C for an or operation.

[0020]FIG. 3 is a schematic diagram depicting the values of x, y, M_(x), M_(y), C_(x), C_(y), M and C for an and operation.

[0021]FIG. 4 is a schematic diagram depicting the values of x, y, M_(x), M_(y), C_(x), C_(y), M and C for an xor operation.

[0022]FIG. 5 is a schematic diagram depicting the values of x, y, M_(x), M_(y), C_(x), C_(y), M and C for an addition operation.

[0023]FIG. 6 is a schematic diagram depicting the values of x, y, M_(x), M_(y), C_(x), C_(y), M and C for a subtraction operation.

[0024]FIG. 7 is a schematic diagram depicting the values of x, y, M_(x), M_(y), C_(x), C_(y), M and C for a shift left logic operation.

DESCRIPTION OF THE SPECIFIC EMBODIMENTS

[0025] The invention will now be described with reference to the specific embodiments. Generally, the invention relates to methods for simplifying expressions at compiler time to reduce the number and complexity of CPU operations required to evaluate the expressions at run time.

[0026] To illustrate the value of the simplifications, consider a function ƒ(x, y, . . . , z) that has an integer result and integer arguments (operands). Each argument is considered as a set of bits. For example, in the case of a 4-bit integer representation (e.g., the constant 2 has a bit set equal to {0,0,1,0}) an argument x has a bit set {x3, x2, x1, x0}, where x3, . . . , x0 are unknown and each may have the value 0 or 1. A result bit set can be calculated for this function ƒ, and this result bit set may have a variable or a constant located at each bit position, depending on whether the values of individual bits of the operands are variable or constant. For example, the function ƒ(x)=x|2 has the binary or operation applied to the bit sets of its arguments {x3, x2, x1, x0}|{0,0,1, 0}, resulting in the bit set {x3 ,x2, 1 x0}. If all bits of a result set are constants, then the function is equivalent to this constant, for example x*0 is equivalent to 0.

[0027] If a complex function consists of small subfunctions, then the result bit set is propagated by means of an induction method. For example, consider the function ƒ(x)=((x|3)*11) & 3. The result bit set for a four-bit representation is calculated as follows: (({x3, x2, x1, x0}|{0, 0, 1, 1}) * {1, 0, 1, 1})&{0, 0, 1, 1} = ({x3, x2, 1, 1} * {1, 0, 1, 1})&{0, 0, 1, 1} = {x3 + x2, x2, 0, 1}&{0, 0, 1, 1} = {0, 0, 0, 1}

[0028] So function ƒ(x) is equivalent to constant 1.

[0029] Similarly, if ƒ(x)=((x|13)*11) & 6, then the result bit set is: (({x3, x2, x1, x0}|{0, 0, 1, 1}) * {1, 0, 1, 1})&{0, 0, 1, 1} = ({x3, x2, 1, 1} * {1, 0, 1, 1})&{0, 0, 1, 1} = {x3 + x2, x2, 0, 1}&  {0, 1, 1, 0} = {0, x2, 0, 0} = {x3, x2, x1, 0}&  {0, 1, 0, 0}

[0030] Thus,ƒ(x)=x & 4. At runtime, calculating x & 4 will produce the same result as calculating ((x|3)*11) & 6, but with fewer operations.

[0031] To enable a compiler to identify such simplifications, an embodiment of the present invention calculates bit sets on which operations can be performed to determine appropriate simplifications. For each operand, two bit sets are defined. One is an operand-constant bit set (denoted M_(x), for operand x) that is defined such that the value of a bit in M_(x) indicates whether the corresponding bit in operand x has a constant (known) or non-constant (variable) value at compile time. In a preferred embodiment, a given bit in M_(x) has value 1 if the corresponding bit in operand x has a constant value, value 0 otherwise. The other is an operand-value bit set (denoted C_(x) for operand x), defined such that the value of a bit in C_(x) indicates the value of a corresponding bit in operand x, if that bit in operand x is constant at compile time. In a preferred embodiment, a given bit in C_(x) has value 1 if the corresponding bit in operand x has constant value 1; the bit has value 0 if the corresponding bit in operand x has constant value 0 or non-constant value.

[0032]FIG. 1 depicts the steps implemented by an embodiment of the invention: first the M and C bit sets are calculated for the operands; second, the M and C bit sets of the operands are utilized to calculate the M and C bit sets of the results; third, the result M and C bit sets are utilized to calculate the non-influence bit sets; and, finally, the non-influence bit sets are stored for use in simplifying expressions at compile time.

[0033] In a preferred embodiment the following four sets are calculated from the operand bit sets:

[0034] 1. A set of bits indicating which bits in the result of an operation are known to be constant, called the result-constant bit set (M). In an example embodiment, a bit in set M has value 1 when the corresponding bit in the result is constant, 0 when the corresponding bit is not constant.

[0035] 2. A set of values for the constant bits in the result, called the result-value bit set (C). This set indicates the values, i.e., 0 or 1, of the constant bits in the result-constant bit set. In an example embodiment, when a bit in the result is not constant the corresponding bit in C has value 0.

[0036] 3. A set of non-influence bits for each operand, indicating which bits of the operand do not influence the value of the result. This set is called the operand non-influence set (N_(x) for operand x). In an example embodiment, a bit in this set has value 0 when the corresponding bit in the operand does not influence the result of the operation, 1 when the corresponding bit can influence the result.

[0037] 4. The intersection of the non-influence bit sets of each operand indicating the bit positions in the operands that have no influence on the result and thus are not required to be processed. This set is called the non-influence intersection set (N).

[0038] These sets can be used by a compiler to determine simplified expressions that are equivalent to the initial expressions. Substitution of the simplified expression in the executable code reduces the CPU load at runtime, resulting in more efficient program execution.

Specific Algorithms

[0039] For each operation, an algorithm is provided to the compiler to calculate the sets M and C, as well as N_(x) and N in cases where these last two sets are useful. By way of illustration, specific algorithms for determining sets M, C, N_(x), and N are provided below for the following operations: ˜ binary negation (not) | binary or (or) & binary and (and) ^ binary nonequivalence (xor) + integer addition (add) − integer subtraction (sub) * integer multiply (mul) << shift left logic (sll) >> shift right logic (srl) >>> shift right arithmetic (sra)

[0040] A general overview of the operation of this embodiment is currently depicted in the flow chart 10 of FIG. 1. First, in step 12, the compiler will utilize standard techniques to identify expressions in the code. Following step 12, step 14 processes the operands to obtain the constant bit set (CBS) and value bit set (VBS) for each operand. As described in detail below, these bit sets are obtained by performing logical operations on the operand bit sets. Which operations are performed depends on the operations included in the expression. The operand bit sets are processed to obtain the result CBS and VBS in step 16. Thus, the result bit sets are obtained solely from processing the known operand bits sets based on the operations included in the expression.

[0041] Finally, in step 18, the result bit sets may be processed to obtain a non-influence bit set identifying bits in the operands that do not influence the value of the result, ending with step 20. Alternatively, a decision may be made to return to step 14 to repeat operand processing. As illustrated below, the non-influence bit set may be utilized to simplify expressions at the compiler level so that the number of cycles scheduled for run-time to execute the expression can be reduced.

[0042] 1. Algorithm for not Operation.

[0043] The following algorithm can be used to calculate the result-constant bit set M and the result-value bit set C from bit sets M_(x), C_(x) for the not operation (˜x):

M=M _(x);

C=˜C _(x) & M.

[0044] These equations signify that a bit in ˜x is constant when the corresponding bit in x is constant. The known bits in ˜x will have opposite values from the corresponding bits in x, and the bits in C have value 1 only if the corresponding bit in x is known.

[0045] For example, consider the case where x={1, x2, x1, 0}. Then the operand known-bit set M_(x) is {1,0,0,1} and the operand-value bit set C_(x) is {1,0,0,0}, indicating that the highest bit of x has constant value 1, the lowest bit of x has constant value 0, and the middle two bits have variable values. Applying the above algorithm to the example operand yields:

M={1,0,0,1};

C=˜{1,0,0,0}&{1,0,0,1}={0,1,1,1}& {1,0,0,1}={0,0,0,1}.

[0046] The presence of bit value 1 in the high and low positions of set M indicates that the values of the corresponding bits of ˜x are known. From the values in corresponding positions of set C, it follows that the highest bit in ˜x has value 0 and the lowest bit has value 1.

[0047] The non-influence set for this operation is not of much interest; clearly every bit in x influences the result of ˜x.

[0048] 2. Algorithm for OR Operation.

[0049]FIG. 2 is a diagrammatic illustration of bit sets M_(x), M_(y), C_(x), C_(y) calculated from similar bit sets M and C using the OR operation x|y:

C=C _(x) |C _(y);

M=M _(x)&M _(y) |C.

N _(x) =C _(y) |N;

N _(y) =C _(x) |N

[0050] For example, take x|y in which x={1, x2, x1, 0} and y={y3, 1, y1, 0}. Then, employing the relationships set forth above, as illustrated in FIG. 2,

M _(x)={1,0,1,1}, C _(x)={1,0,0,0,}(row 22, FIG. 2) and

M _(y)={0,1,0,1}, C _(y)={0,1,0,0,}(row 24).

[0051] The result, as shown in row 26, will be C = {1, 0, 0, 0}|{0, 1, 0, 0} = {1, 1, 0, 0}, and $\begin{matrix} {M = \left. {{\left\{ {1,0,1,1} \right\}\&}\quad \left\{ {0,1,0,1} \right\}} \middle| \left\{ {1,1,0,0} \right\} \right.} \\ {= \left. \left\{ {0,0,0,1} \right\} \middle| \left\{ {1,1,0,0} \right\} \right.} \\ {= {\left\{ {1,1,0,1} \right\}.}} \end{matrix}$

[0052] Note that the ones in M_(x) and M_(y) correspond to the location of know bit in the associated variable.

[0053] Thus, for this example, the values of all bits in (x|y) except the second lowest bit are known, as indicated by the 1's in set M. The two highest bits each have constant value 1 as indicated by the 1's in set C, and the lowest bit has constant value 0, as indicated by the 0 in that position in set C.

[0054] The non-influence sets for the two operands in the or operation are calculated with the following algorithm:

N _(x) =C _(y) |N,

[0055] and

N _(y) =C _(x) |N.

[0056] That is, a bit in operand x(y) does not affect the result if the corresponding bit in operand y(x) is fixed and its value is 1; in any other case, the bit in operand x(y) does affect the result.

[0057] In the example where x={1, x2, x1, 0}, and y={y3, 1, y1, 0}, and N={0,0,0,0}, the algorithm yields:

N _(x)={0,1,0,0}|{0,0,0,0}={0,1,0,0};

N _(y)={1,0,0,0}|{0,0,0,0}={1,0,0,0},

[0058] The value 1 in the second bit of N_(x) indicates that the (unknown) value of x2 is irrelevant to the result; the value 0 in the third bit indicates that the value of x1 is relevant. Similarly, the value 1 in the highest bit of N_(y) indicates that the value of y3 is irrelevant to the result, and the value 0 in the third bit indicates the value of y1 is relevant.

[0059] 3. Algorithm for and Operation.

[0060]FIG. 3 diagrammatically illustrates the calculation of bit sets M, C from similar bit sets M_(x), M_(y), C_(x), C_(y) for the and operation x & y:

M=M _(x)&M _(y) |M _(x)&˜C _(x) |M _(y)&˜C _(y);

C=C _(x)&C _(y).

N _(x) =C _(y) |N;

N _(y) =C _(x) |N _(z)

[0061] Note that the 1's in M_(x) and M_(y) correspond to the location of the known bit in the associated variable. FIG. 3 illustrates x & y with M_(x)={1,0,1,1}, C_(x)={0,0,1,1} and M_(y)={0,1,0,1}, C_(y)={0,0,0,1} to achieve: $\begin{matrix} {M = \quad {\left. {\left. {\left. {{\left\{ {1,0,1,1} \right\} \quad\&}\left\{ {0,1,0,1} \right\}} \middle| \left\{ {1,0,1,1} \right\} \right.\&} \right.\sim\left\{ {0,0,1,1} \right\}} \middle| \left\{ {0,1,0,1} \right\} \right.\&}} \\ {\quad {\sim\left\{ {0,0,0,1} \right\}}} \\ {= \quad {{\left. {{\left. \left\{ {0,0,0,1} \right\} \middle| \left\{ {1,0,0,1} \right\} \right.\&}\left\{ {1,1,0,0} \right\}} \middle| \left\{ {0,1,0,1} \right\} \right.\&}\quad \left\{ {1,1,1,0} \right\}}} \\ {= \quad \left. \left\{ {0,0,0,1} \right\} \middle| \left\{ {1,0,0,\left. 0 \middle| \left\{ {0,1,0,0} \right\} \right.} \right. \right.} \\ {= \quad \left. \left\{ {1,0,0,1} \right\} \middle| \left\{ {0,1,0,0} \right\} \right.} \\ {{= \quad \left\{ {1,1,0,1} \right\}};} \end{matrix}$ C = {0, 0, 1, 1}  &  {0, 0, 0, 1} = {0, 0, 0, 1}.

[0062] As a farther example, consider the case where x={1, x2, x1, 0} and y={y3, 1, y1, 0}, and N={0,0,0,0}. As before, M_(x)={1,0,0,1}, C_(x)={1,0,0,0} and M_(y)={0,1,0,1}, C_(y)={0,1,0,0}. The and algorithm yields: $\begin{matrix} {M = \quad {\left. {\left. {\left. {{\left\{ {1,0,0,1} \right\} \quad\&}\left\{ {0,1,0,1} \right\}} \middle| \left\{ {1,0,0,1} \right\} \right.\&} \right.\sim\left\{ {1,0,0,1} \right\}} \middle| \left\{ {0,1,0,1} \right\} \right.\&}} \\ {\quad {\sim\left\{ {0,1,0,0} \right\}}} \\ {= \quad {{{{\left. \left\{ {0,0,0,1} \right\} \middle| \left\{ {1,0,0,1} \right\} \right.\&}\quad \left\{ {0,1,1,1} \right\}}\&}\quad \left\{ {1,0,1,1} \right\}}} \\ {= \quad \left. \left\{ {0,0,0,1} \right\} \middle| \left\{ {0,0,0,1} \right\} \middle| \left\{ {0,0,0,1} \right\} \right.} \\ {= \quad \left. \left\{ {0,0,0,1} \right\} \middle| \left\{ {0,0,0,1} \right\} \right.} \\ {{= \quad \left\{ {0,0,0,1} \right\}};} \end{matrix}$ C = {1, 0, 0, 0}  &  {0, 1, 0, 0} = {0, 0, 0, 0};

[0063] So the lowest bit of x & y is known and equals 0. Other bits of x & y are not known.

[0064] For x & y, the non-influence sets are calculated via the following algorithm:

N _(x) =M _(y)&˜C _(y) |N;

N _(y) =M _(x)&˜C _(x) |N.

[0065] That is, a bit in operand x(y) is irrelevant only when the corresponding bit in operand y(x) has constant value 0. Thus, for the example operands above:

N _(x)={0,1,0,1}&˜{0,1,0,0}|{0,0,0,0}={0,1,0,1}&{1,0,1,1}={0,0,0,1};

N _(y)={1,0,0,1}&˜{1,0,0,0}|{0,0,0,0}={1,0,0,1}&{0,1,1,1}={0,0,0,1}.

[0066] 4. Algorithm for xor Operation

[0067]FIG. 4 is a diagrammatic illustration of the relationship of x, y, M_(x), M_(y), C_(x), C_(y), M and C an xor (x^ y) operation. Note that the ones in M_(x) and M_(y) correspond to the location of know bit in the associated variable. The technique for calculating M and C from M_(x), M_(y), C_(x), and C_(y) will now be described. FIG. 4 illustrates the calculation of M, C from bit sets M_(x)={1,0,1,1}, C_(x)={1,0,0,1} and M_(y)={0,1,1,1}, C_(y)={0,0,1,1} for an exclusive or operation (x^ y):

M=M _(x)&M _(y);

C=(C _(x) ^ C _(y))&M;

N _(x) =N;

N _(y) =N.

[0068] As FIG. 4 illustrates for the bit sets and relationships presented above, the results will be M = {1, 0, 1, 1}  &  {0, 1, 1, 1} = {0, 0, 1, 1} $\begin{matrix} {C = \left. {{{\left( {\left\{ {1,0,0,1} \right\}\bigwedge\left\{ {0,0,1,1} \right\}} \right)\&}\quad \left\{ {0,0,1,1} \right\}} = {{\left\{ {1,0,1,0} \right\} \quad\&}\quad \left\{ {0,0,1,1} \right.}} \right)} \\ {{= \left\{ {0,0,1,0} \right\}};} \end{matrix}$ N_(x) = N = {0, 0, 0, 0}; N_(y) = N = {0, 0, 0, 0}.

[0069] As another example, consider the case of x={1, x2 x1, 0} and y={y3, 1, y1, 0}. As before, M_(x)={1,0,0,1}, C_(x)={1,0,0,0} and M_(y)={0,1,0,1}, C_(y)={0,1,0,0}. The above algorithm for xor yields:

M={1,0,0,1}&{0,1,0,1}={0,0,0,1};

C=({1,0,0,0}^ {0,1,0,0})&{0,0,0,1}={1,1,0,0}&{0,0,0,1}={0,0,0,0};

[0070] That is, the lowest bit of x^ y has constant value 0. The other bits are not known.

[0071] For x^ y, the operand non-influence sets are:

N _(x) =N={0,0,0,0};

N _(y) =N={0,0,0,0}.

[0072] This signifies that each bit in both operands is always relevant in operation xor.

[0073] 5. Algorithm for ADDITION Operation

[0074]FIG. 5 is a schematic diagram depicting the relationship of x, y, M_(x), M_(y), C_(x), C_(y), M and C for a concrete example of an ADDITION operation. Note that the ones in M_(x) and M_(y) correspond to the location of know bit in the associated variable. The technique for calculating M and C from M_(x), M_(y), C_(x), and C_(y) will now be described.

[0075] The following algorithm can be used to calculate bit sets M, C from bit sets M_(x), C_(x), M_(y), C_(y) for operation x+y:

[0076] First, calculate a preliminary set C=C_(x)+C_(y).

[0077] Then use this preliminary set C to calculate M according to the following equation:

M=M _(x)&M _(y)&(C^ ˜((C _(x) |˜M _(x))+(C _(y) |˜M _(y))))&(C^ ˜(C _(x)+(C _(y) |˜M _(y))))&(C^ ˜((C _(x) |˜M _(x))+C _(y))).

[0078] Finally, use the values of M and the preliminary set C to calculate the final result-value bit set:

C=C&M;

[0079] The last step enforces the convention that a bit in C is 0 when the bit in the result is not known.

[0080]FIG. 5 illustrates the x+y operation for the bit sets M_(x)={1,1,0,1}, C_(x)={0,1,0,1} and M_(y)={1,1,1,0}, C_(y)={1,1,1,0}. C, M, C, N_(x), and N_(y), using the above-identified relationships, first obtain C

C={0,1,0,1}+{1,1,0,0}={0,0,0,1};

[0081] Then, using C, determine M ${M = {{{{{\left\{ {1,1,0,1} \right\} \quad\&}\quad \left\{ {1,1,1,0} \right\}}\&}\quad \left( {{{{{\left\{ {0,0,0,1} \right\}\hat{}{\sim\left( \left( \left\{ {0,1,0,1} \right\} \middle| {{\sim\left\{ {1,1,0,1} \right\}} + \left( \left\{ {1,1,0,0} \right\} \middle| {\sim\left\{ {1,1,1,0} \right\}} \right)} \right) \right)}}\&}\quad \left( {\left\{ {0,0,0,1} \right\}\hat{}{\sim\left( {\left\{ {0,1,0,1} \right\} + \left( \left\{ {1,1,0,0} \right\} \middle| {\sim\left\{ {1,1,1,0} \right\}} \right)} \right)}} \right)}\&}\quad \left( {\left\{ {0,0,0,1} \right\}\hat{}{\sim\left( {\left( \left\{ {0,1,0,1} \right\} \middle| {\sim\left\{ {1,1,0,1} \right\}} \right) + \left\{ {1,1,0,0} \right\}} \right)}} \right)} \right)} = {{{{{{{\left\{ {1,1,0,0} \right\}\&}\left( {\left\{ {0,0,0,1} \right\}\hat{}{\sim\left( {\left( \left\{ {0,1,0,1} \right\} \middle| \left\{ {0,0,1,0} \right\} \right) + \left( \left\{ {1,1,0,0} \right\} \middle| \left\{ {0,0,0,1} \right\} \right)} \right)}} \right)}\&}\quad \left( {\left\{ {0,0,0,1} \right\}\hat{}{\sim\left( {\left\{ {0,1,0,1} \right\} + \left( \left\{ {1,1,0,0} \right\} \middle| \left\{ {0,0,0,1} \right\} \right)} \right)}} \right)}\&}\quad \left( {\left\{ {0,0,0,1} \right\}\hat{}{\sim\left( {\left. \left. \left( \left\{ {0,1,0,1} \right\} \middle| \left\{ {0,0,1,0} \right. \right. \right) \right\} + \left\{ {1,1,0,0} \right\}} \right)}} \right)} = {{{{{{{\left\{ {1,1,0,0} \right\}\&}\quad \left( {\left\{ {0,0,0,1} \right\}\hat{}{\sim\left( {\left\{ {0,1,1,1} \right\} + \left\{ {1,1,0,1} \right\}} \right)}} \right)}\&}\quad \left( {\left\{ {0,0,0,1} \right\}\hat{}{\sim\left( {\left\{ {0,1,0,1} \right\} + \left\{ {1,1,0,1} \right\}} \right)}} \right)}\&}\left( {\left\{ {0,0,0,1} \right\}\hat{}{\sim\left( {\left\{ {0,1,1,1} \right\} + \left\{ {1,1,0,0,} \right\}} \right)}} \right)} = {{{{{{{\left\{ {1,1,0,0} \right\}\&}\quad \left( {\left\{ {0,0,0,1} \right\}\hat{}{\sim\left\{ {0,1,0,0} \right\}}} \right)}\&}\quad \left( {\left\{ {0,0,0,1} \right\}\hat{}{\sim\left\{ {0,0,1,0} \right\}}} \right)}\&}\quad \left( {\left\{ {0,0,0,1} \right\}\hat{}{\sim\left\{ {0,0,1,1} \right\}}} \right)} = {{{{{{{\left\{ {1,1,0,0} \right\}\&}\quad \left( {\left\{ {0,0,0,1} \right\}\hat{}\left\{ {1,0,1,1} \right\}} \right)}\&}\quad \left( {\left\{ {0,0,0,1} \right\}\hat{}\left\{ {1,1,0,1} \right\}} \right)}\&}\quad \left( {\left\{ {0,0,0,1} \right\}\hat{}\left\{ {1,1,0,0} \right\}} \right)} = {{{{{{{\left\{ {1,1,0,0} \right\}\&}\left\{ {1,0,1,0} \right\}}\&}\left\{ {1,1,0,0} \right\}}\&}\left\{ {1,1,0,1} \right\}} = {{{\left\{ {1,0,0,0} \right\}\&}\left\{ {1,1,0,0} \right\}} = \left\{ {1,0,0,0} \right\}}}}}}}}};$ C = {0, 0, 0, 1}  &{1, 0, 0, 0} = {0, 0, 0,}; N_(x) = 0 = {0, 0, 0, 0}; N_(y) = 0 = {0, 0, 0, 0}.

[0082] As another illustration of the ADDITION operation, consider the case of x={1, x2, x1, 0} and y={y3, 1, y1, 0}. Then M_(x)={1,0,0,1}, C_(x)={1,0,0,0} and M_(y)={0,1,0,1}, C_(y)={0,1,0,0}. Then the algorithm yields:

Preliminary C={1,0,0,0}+{0,1,0,0}={1,1,0,0};

[0083] $\begin{matrix} {M = \quad {{{\left\{ {1,0,0,1} \right\}\&}\quad \left\{ {0,1,0,1} \right\}}\&}} \\ {\quad \left( {{\left\{ {1,1,0,0} \right\}\hat{}{\sim\left( \left. \left( {1,0,0,0} \right. \right\} \middle| {\sim\left\{ {1,0,0,1} \right\}} \right)}} +} \right.} \\ {{\left. {\quad \left. \left( \left\{ {0,1,0,0} \right\} \middle| {\sim\left\{ {0,1,0,1} \right\}} \right) \right)} \right)\&}\quad \left. \left. \left( {1,1,0,0} \right. \right\}\hat{} \right.\sim} \\ {{\quad \left. \left( {\left( \left\{ {1,0,0,0} \right\} \right) + \left( \left\{ {0,1,0,0} \right\} \middle| {\sim\left\{ {0,1,0,1} \right\}} \right)} \right) \right)}\&} \\ {\quad \left. \left( {\left\{ {1,1,0,0} \right\}\hat{}{\sim\left( {\left( \left\{ {1,0,0,0} \right\} \middle| {\sim\left\{ {1,0,0,1} \right\}} \right) + \left. \left( {0,1,0,0} \right. \right\}} \right)}} \right) \right)} \\ {= \quad \left( {\left\{ {1,1,0,0} \right\}\hat{}{\sim\left( {\left( \left\{ {1,0,0,0} \right\} \middle| \left\{ {0,1,1,0} \right\} \right) +} \right.}} \right.} \\ {{\left. {\quad \left. \left( \left\{ {0,1,0,0} \right\} \middle| \left\{ {1,0,1,0} \right\} \right) \right)} \right)\quad\&}\quad \left( \left. \left\{ {1,1,0,0} \right\}\hat{} \right.\sim \right.} \\ {{{\quad \left. \left( {\left( \left\{ {1,0,0,0} \right\} \right) + \left( \left\{ {0,1,0,0} \right\} \middle| \left\{ {1,0,1,0} \right\} \right)} \right) \right)}\&}\quad} \\ {\quad {\left. \left( \left\{ {1,1,0,0} \right. \right. \right)\hat{}{\sim\left( \left( \left\{ {1,0,0,0} \right\} \middle| {\left\{ {0,1,1,0} \right\} + \left( \left\{ {0,1,0,0} \right\} \right)} \right) \right)}}} \\ {\left. {= \quad \left( {\left\{ {1,1,0,0} \right\}\hat{}{\sim\left( {\left\{ {1,1,1,0} \right\} + \left\{ {1,1,1,0} \right\}} \right)}} \right)} \right)\&} \\ {\quad \left( {\left\{ {1,1,0,0} \right\}\hat{}{\sim\left( {\left\{ {1,1,1,0} \right\} + \left\{ {0,1,0,0} \right\}} \right)}} \right)} \\ {= \quad {{\left( {\left\{ {1,1,0,0} \right\}\hat{}{\sim\left\{ {1,1,0,0} \right\}}} \right)\&}\quad \left( {\left\{ {1,1,0,0} \right\}\hat{}{\sim\left\{ {0,0,1,0} \right\}}} \right)}} \\ {= \quad {{\left( {\left\{ {1,1,0,0} \right\}\hat{}\left\{ {0,0,1,1} \right\}} \right)\&}\quad \left( {{\left\{ {1,1,0,0} \right\}\hat{}\quad \left\{ {1,0,0,1} \right\}}\&} \right.}} \\ {\quad \left( {\left\{ {1,1,0,0} \right\}\hat{}\left\{ {1,1,0,1} \right\}} \right)} \\ {= \quad {{{{{\left\{ {1,1,1,1} \right\}\&}\left\{ {0,1,0,1} \right\}}\&}\quad \left\{ {0,0,0,1} \right\}} = {\left\{ {0,1,0,1} \right\} +}}} \\ {\quad \left\{ {0,0,01} \right\}} \end{matrix}$

[0084] Thus: M={0,0,0,1};

C={1,1,0,0}& {0,0,0,1}={1,1,0,0}

[0085] The low-order bit of x +y is known and equal to 0. Other bits are not known.

[0086] For x+y, the operand non-influence sets are:

N _(x)=0={0,0,0,0};

N _(y)=0={0,0,0,0}.

[0087] This signifies that each bit in both operands is always relevant in operation add.

[0088] 6. Algorithm for SUBTRACTION Operation

[0089]FIG. 6 is a schematic diagram depicting the relationship of x, y, M_(x), M_(y), C_(x), C_(y), M and C for a concrete example of an SUBTRACTION operation. Note that the ones in M_(x) and M_(y) correspond to the location of know bit in the associated variable. The technique for calculating M and C from M_(x), M_(y), C_(x), and C_(y) will now be described.

[0090] The following algorithm can be used to calculate bit sets M, C from bit sets M_(x), C_(x), M_(y), C_(y) for operation x−y:

C=C _(x) −C _(y);

M=M _(x)&M _(y)&(C^ ˜(( C _(x) |˜M _(x))−(C _(y) |˜M _(y))))&(C^ ˜(C _(x)−(C _(y) |˜M _(y))))&(C^ ˜((C _(x) |˜M _(x))−C _(y)));

C=C&M.

[0091]FIG. 6 illustrates calculating bits sets M and C from similar bit sets M_(x), C_(x), M_(y), and C_(y) for the SUBTRACTION operation, x−y, using the relationships set forth above. Thus, C = {0, 1, 0, 1} − {1, 1, 0, 0} = {1, 0, 0, 1}; $M = {{{{{{{{{\left\{ {1,1,0,1} \right\}\&}\left\{ {1,1,1,0} \right\}}\&}\quad \left( {\left\{ {1,0,0,1} \right\}\hat{}{\sim\left( {\left( \left\{ {0,1,0,1} \right\} \middle| {\sim\left\{ {1,1,0,1} \right\}} \right) - \left( \left\{ {1,1,0,0} \right\} \middle| {\sim\left\{ {1,1,1,0} \right\}} \right)} \right)}} \right)}\&}\left( {\left\{ {1,0,0,1} \right\}\hat{}{\sim\left( {\left\{ {0,1,0,1} \right\} - \left( \left\{ {1,1,0,0} \right\} \middle| {\sim\left\{ {1,1,1,0} \right\}} \right)} \right)}} \right)}\&}\left( {\left\{ {1,0,0,1} \right\}\hat{}{\sim\left( {\left( \left\{ {0,1,0,1} \right\} \middle| {\sim\left\{ {1,1,0,1} \right\}} \right) - \left\{ {1,1,0,0} \right\}} \right)}} \right)} = \left\{ {1,\quad 1,\quad 0,0} \right\}}$

[0092] Again consider the case where x={1, x2, x1, 0} and y={y3, 1, y1, 0}. Then M_(x)={1,0,0,1}, C_(x)={1,0,0,0} and M_(y)={0,1,0,1}, C_(y)={0,1,0,0}. Then the algorithm yields: C = {1, 0, 0, 0} − {0, 1, 0, 0} = {0, 1, 0, 0}; $\begin{matrix} {{M = \quad {{{\left\{ {1,0,0,1} \right\}\&}\quad \left\{ {0,1,0,1} \right)}\&}}\quad} \\ {\quad \left( {\left\{ {1,1,0,0} \right\}\hat{}{\sim\left( {\left( {{\left\{ {1,0,0,0} \right\} \left. {\sim\left\{ {1,0,0,1} \right\}} \right)} - \left( {\left\{ {0,1,0,0} \right\} \left. {\sim\left\{ {0,1,0,1} \right\}} \right)} \right)} \right)\&} \right.}} \right.} \\ {\quad \left( {{\left\{ {1,1,0,0} \right\}\hat{}{\sim\left( {\left( \left\{ {1,0,0,0} \right\} \right) - \left( {\left\{ {0,1,0,0} \right\} \left. {\sim\left\{ {0,1,0,1} \right\}} \right)} \right)} \right)}}\&} \right.} \\ {\quad \left( {\left\{ {1,1,0,0} \right\}\hat{}{\sim\left( \left( {{\left\{ {1,0,0,0} \right\} \left. {\sim\left\{ {1,0,0,1} \right\}} \right)} - \left( \left\{ {0,1,0,0} \right\} \right)} \right) \right)}} \right.} \\ {= \quad \left( {\left\{ {1,1,0,0} \right\}\hat{}{\sim\left( {\left( {{\left\{ {1,0,0,0} \right\} \left. \left\{ {0,1,1,0} \right\} \right)} - \left( {\left\{ {0,1,0,0} \right\} \left. \left\{ {1,0,1,0} \right\} \right)} \right)} \right)\&} \right.}} \right.} \\ {\quad \left( {{\left\{ {1,1,0,0} \right\}\hat{}{\sim\left( {\left( \left\{ {1,0,0,0} \right\} \right) - \left( {\left\{ {0,1,0,0} \right\} \left. \left\{ {1,0,1,0} \right\} \right)} \right)} \right)}}\&} \right.} \\ {\quad \left( {\left\{ {1,1,0,0} \right\}\hat{}{\sim\left( \left( {{\left\{ {1,0,0,0} \right\} \left. \left\{ {0,1,1,0} \right\} \right)} - \left( \left\{ {0,1,0,0} \right\} \right)} \right) \right)}} \right.} \\ {= \quad {\left( {\left\{ {1,1,0,0} \right\}\hat{}{\sim\left( {\left\{ {1,1,1,0} \right\} - \left\{ {1,1,1,0} \right\}} \right)}} \right)\&}} \\ {\quad {\left( {\left\{ {1,1,0,0} \right\}\hat{}{\sim\left( {\left\{ {1,0,0,0} \right\} - \left\{ {1,1,1,0} \right\}} \right)}} \right)\&}} \\ {\quad \left( {\left\{ {1,1,0,0} \right\}\hat{}{\sim\left( {\left\{ {1,1,1,0} \right\} - \left\{ {0,1,0,0} \right\}} \right)}} \right)} \\ {= \quad {{{\left( {\left\{ {1,1,0,0} \right\}\hat{}{\sim\left\{ {0,0,0,0} \right\}}} \right)\&}\quad \left( {\left\{ {1,1,0,0} \right\}\hat{}{\sim\left\{ {1,0,1,0} \right\}}} \right)}\&}} \\ \left. \quad {\left\{ {1,1,0,0} \right\}\hat{}{\sim\left\{ {1,0,1,0} \right\}}} \right) \\ {= \quad {{{\left( {\left\{ {1,1,0,0} \right\}\hat{}\left\{ {1,1,1,1} \right\}} \right)\&}\quad \left( {\left\{ {1,1,0,0} \right\}\hat{}\left\{ {0,1,0,1} \right\}} \right)}\&}} \\ {\quad \left( {\left\{ {1,1,0,0} \right\}\hat{}\left\{ {0,1,0,1} \right\}} \right)} \\ {= \quad {{{{\left\{ {0,0,1,1} \right\}\&}\quad \left\{ {1,0,0,1} \right\}}\&}\quad \left\{ {1,0,0,1} \right\}}} \\ {= \quad {{\left\{ {0,0,0,1} \right\}\&}\quad \left\{ {1,0,0,1} \right\}}} \end{matrix}$

[0093] Thus: M={0,0,0,1}.

C={0,1,0,0}&{0,0,0,1}={0,0,0,0};

[0094] So the low-order bit of x−y is known and equal to 0. Other bits are not known.

[0095] For x−y, the operand non-influence sets are:

N _(x)=0={0,0,0,0};

N _(y)=0={0,0,0,0}.

[0096] This signifies that each bit in both operands is always relevant in operation sub.

[0097] 7. Algorithm for MULTIPLY Operation

[0098] The following algorithm can be used to calculate bit sets M, C from similar bit sets M_(x), C_(x), M_(y), C_(y) for operation x*y:

[0099] Step 1:

[0100] M=−(M_(y) & 1);

[0101] C=−(C_(y) & 1);

[0102] M=M_(x) & M|M_(x) & ˜C_(x)|M_(y) & ˜C_(y);

[0103] C=C & C_(x);

[0104] i=1;

[0105] Step 2:

[0106] If i>=size of C in bits, go to Quit;

[0107] Step 3:

[0108] M_(x)=M_(x)<<1;

[0109] M_(x)=M_(x)|1;

[0110] C_(x)=C_(x)<<1;

[0111] M_(y)=M_(y)>>1;

[0112] C_(y)=C_(y)>>1;

[0113] M_(yy)=−(M_(y) & 1);

[0114] C_(y)y=−(C_(y) & 1);

[0115] M_(yy=M) _(x) & M_(yy)|M_(x) & ˜C_(x)|M_(y) & ˜C_(yy);

[0116] C_(yy)=C_(yy) & C_(x);

[0117] CC=C+C_(yy);

[0118] M=M & M_(yy) & (CC^ ˜((C|˜M)+(C_(yy)|˜M_(yy)))) & (CC^ ˜(C+(C_(yy)|˜M_(yy)))) & (CC^ ˜((C|˜M)+C_(yy)));

[0119] C=CC & M;

[0120] i=i+1;

[0121] go to Step 2;

[0122] Quit.

[0123] Here the sets M_(yy), C_(yy), CC are temporary sets.

[0124] As an example, consider the case where x={1, x2, x1, 0} and y={y3, 1, y1, 0}. Then M_(x)={1,0,0,1}, C_(x)={1,0,0,0} and M_(y)={0,1,0,1}, C_(y)={0,1,0,0}. Then the algorithm proceeds as follows: ${{{{{{{{{\text{Step 1:}\quad {{M = {{- \left( {{M_{y}\quad\&}\quad 1} \right)} = {{- \left( {{\left\{ {0,1,0,1} \right\} \quad\&}\quad \left\{ {0,0,0,1} \right\}} \right)} = {{- \left\{ {0,0,0,1} \right\}} = \left\{ {1,1,1,1} \right\}}}}};}\quad {{C = {{- \left( {{C_{y}\quad\&}\quad 1} \right)} = {{- \left( {{\left\{ {0,1,0,0} \right\} \quad\&}\quad \left\{ {0,0,0,1} \right\}} \right)} = {{- \left\{ {0,0,0,1} \right\}} = \left\{ {0,0,0,0} \right\}}}}};}\quad \begin{matrix} {{{\left. {{{\left. {M = {{\left( {\sim C_{x}} \right.}C}} \right)\quad\&}\quad M_{x}}} \right.\sim C}\quad\&} - \left( {{M_{y}\quad\&}\quad 1} \right)} \\ {{\left. {\left. {{{\left. {= {{\left( {\sim\left\{ {1,0,0,0} \right\}} \right.}\left\{ {1,1,1,1} \right\}}} \right)\quad\&}\quad \left\{ {1,0,0,1} \right\}}} \right.\sim\left\{ {1,1,1,1} \right.} \right)\quad\&} - \left( {{\left\{ {0,1,0,1} \right\} \quad\&}\quad \left\{ {0,0,0,1} \right\}} \right)} \\ {{\left. {{{{\left. {= \left. {{\left( \left\{ {0,1,1,1} \right\} \right.}\left\{ {1,1,1,1} \right.} \right)} \right)\quad\&}\quad \left\{ {1,0,0,1} \right\}}}\left\{ {0,0\quad,0,0} \right.} \right)\quad\&} - \left\{ {0,0,0,1} \right\}} \\ {{\left. {{{= {{\left\{ {1,1,1,1} \right\} \quad\&}\quad \left\{ {1,0,0,1} \right\}}}}\left\{ {0,0,0,0} \right.} \right)\quad\&}\quad \left\{ {1,1,1,0} \right\}} \\ {{{{{= \left\{ {1,0,0,1} \right\}}}\left\{ {0,0,0,0} \right\}} = \left\{ {1,0,0,1} \right\}};} \end{matrix}{{C = {{{C\quad\&}\quad C_{x}} = {{{\left\{ {0,0,0,0} \right\} \quad\&}\quad \left\{ {1,0,0,0} \right\}} = \left\{ {1,0,0,0} \right\}}}};}\quad \begin{matrix} {{\left. {{{{\left. {{{{M = {{M_{x}\quad\&}\quad M}}}M_{x}}\quad\&}\quad \right.\sim C_{x}}}M}\quad\&} \right.\sim C};} \\ {\left. {{{{{{{{= {{\left\{ {1,0,0,1} \right\} \quad\&}\quad \left\{ {1,1,1,1} \right\}}}}\left\{ {1,0,0,1} \right\}}\quad\&} - \left\{ {1,0,0,0} \right\}}}\left\{ {1,1,1,1} \right\}}\quad\&} \right.\sim\left\{ {0,0,0,0} \right\}} \\ {{{{{{{{{= \left\{ {1,0,0,1} \right\}}}\left\{ {1,0,0,1} \right\}}\quad\&}\quad \left\{ {0,1,1,1} \right\}}}\left\{ {1,1,1,1} \right\}}\quad\&}\quad \left\{ {1,1,1,1} \right\}} \\ {{{{{{= \left\{ {1,0,0,1} \right\}}}\left\{ {0,0,0,1} \right\}}}\left\{ {1,1,1,1} \right\}} = \left\{ {1,1,1,1} \right\}} \end{matrix}\quad {C = {{{C\quad\&}\quad C_{x}} = {{{\left\{ {0,0,0,0} \right\} \quad\&}\quad \left\{ {1,0,0,0} \right\}} = \left\{ {0,0,0,0} \right\}}}}}\quad {{i = 1};}\quad \text{Step 2:}\quad {{{{{If}\quad i} >}\quad = 4},{{{go}\quad {to}\quad {Quit}};\quad {{\# \quad {here}\quad i}1}}}\quad \text{Step 3:}\quad {M_{x} = {{M_{x}1} = {{\left\{ {1,0,0,1} \right\} 1} = \left\{ {0,0,1,0} \right\}}}}\quad {M_{x} = M_{x}}}}1} = \left\{ {0,0,0,1} \right\}}}\left\{ {0,0,0,1} \right\}} = \left\{ {0,0,1,1} \right\}};}\quad$ C_(x) = C_(x)1 = {1, 0, 0, 0}1 = {0, 0, 0, 0};   M_(y) = M_(y)1 = {0, 1, 0, 1}1 = {0, 0, 1, 0};   C_(y) = C_(y)1 = {0, 1, 0, 0}1 = {0, 0, 1, 0};   M_(yy) = −(M_(y)  &  1) = −({0, 0, 1, 0}  &  {0, 0, 0, 1}) = −{0, 0, 0, 0} = {0, 0, 0, 0};   C_(yy) = −(C_(y)  &  1) = −({0, 0, 1, 0}  &  {0, 0, 0, 1}) = −{0, 0, 0, 0} = {1, 1, 1, 1};   $\begin{matrix} {{\left. {{{{\left. {{{{M_{yy} = {{M_{x}\quad\&}\quad M_{yy}}}}M_{x}}\quad\&} \right.\sim C_{x}}}M_{yy}}\quad\&} \right.\sim C_{yy}}\quad} \\ {\left. {{{{\left. {{{{= {{\left\{ {0,0,1,1} \right\} \quad\&}\quad \left\{ {0,0,0,0} \right\}}}}\left\{ {0,0,1,1} \right\}}\quad\&} \right.\sim\left\{ {0,0,0,0} \right\}}}\left\{ {0,0,0,0} \right\}}\quad\&} \right.\sim\left\{ {0,0,0,0} \right\}} \\ {{{{{= \left\{ {0,0,1,1} \right\}}}\left\{ {0,0,1,1} \right\}}}\left\{ {0,0,0,0} \right\}} \\ {{= \left\{ {0,0,1,1} \right\}};} \end{matrix}\quad$ C_(y)y = C_(yy)  &  C_(x) = {1, 1, 1, 1}  &  {0, 0, 0, 0} = {0, 0, 0, 0};   CC = C + C_(yy) = {1, 0, 0, 0} + {0, 0, 0, 0} = {1, 0, 0, 0}; #  the  CC  is  temporary  set   $\begin{matrix} {M = \quad {{{M\quad\&}\quad M_{yy}}\quad\&}} \\ {\quad \left( {{CC}\hat{}{\sim\left( {\left. {\left. \left( {C{{\sim M}}} \right. \right) + \left. \left. \left( {C_{yy}{{\sim M_{yy}}}} \right. \right) \right)} \right)\quad\&} \right.}} \right.} \\ {\quad \left( {{{CC}\hat{}{\sim\left( {C + \left. \left. \left( {C_{yy}{{\sim M_{yy}}}} \right. \right) \right)} \right)}}\quad\&} \right.} \\ {\quad \left( {{CC}\hat{}{\sim\left( \left. {\left. \left( {C{{\sim M}}} \right. \right) + C_{yy}} \right) \right)}} \right.} \\ {= \quad {{{\left\{ {1,0,0,1} \right\} \quad\&}\quad \left\{ {0,0,1,1} \right\}}\quad\&}} \\ {\quad \left( {\left\{ {1,0,0,0} \right\}\hat{}{\sim\left( {\left. {\left. \left( {\left\{ {1,0,0,0} \right\} {{\sim\left\{ {1,0,0,1} \right\}}}} \right. \right) + \left. \left. \left( {\left\{ {0,0,0,0} \right\} {{\sim\left\{ {0,0,1,1} \right\}}}} \right. \right) \right)} \right)\quad\&} \right.}} \right.} \\ {\quad \left( {{\left\{ {1,0,0,0} \right\}\hat{}{\sim\left( {\left\{ {1,0,0,0} \right\} + \left. \left. \left( {\left\{ {0,0,0,0} \right\} {{\sim\left\{ {0,0,1,1} \right\}}}} \right. \right) \right)} \right)}}\quad\&} \right.} \\ {\quad \left( {\left\{ {1,0,0,0} \right\}\hat{}{\sim\left. {\left. \left( {\left\{ {1,0,0,0} \right\} {{\sim\left\{ {1,0,0,1} \right\}}}} \right. \right) + \left\{ {0,0,0,0} \right\}} \right)}} \right)} \\ {= \quad {\left\{ {0,0,0,1} \right\} \quad\&}} \\ {\quad \left( {\left\{ {1,0,0,0} \right\}\hat{}{\sim\left( {\left. {\left. \left( {\left\{ {1,0,0,0} \right\} {\left\{ {0,1,1,0} \right\}}} \right. \right) + \left. \left. \left( {\left\{ {0,0,0,0} \right\} {\left\{ {1,1,0,0} \right\}}} \right. \right) \right)} \right)\quad\&} \right.}} \right.} \\ {\quad \left( {{\left\{ {1,0,0,0} \right\}\hat{}{\sim\left( {\left\{ {1,0,0,0} \right\} + \left. \left. \left( {\left\{ {0,0,0,0} \right\} {\left\{ {1,1,0,0} \right\}}} \right. \right) \right)} \right)}}\quad\&} \right.} \\ {\quad \left( {\left\{ {1,0,0,0} \right\}\hat{}{\sim\left( \left. {\left. \left( {\left\{ {1,0,0,0} \right\} {\left\{ {0,1,1,0} \right\}}} \right. \right) + \left\{ {0,0,0,0} \right\}} \right) \right)}}\quad \right.} \\ {= \quad {\left\{ {0,0,0,1} \right\} \quad\&}} \\ {\quad \left( {{\left\{ {1,0,0,0} \right\}\hat{}{\sim\left. \left. \left( {\left\{ {1,1,1,0} \right\} + \left\{ \left\{ {1,1,0,0} \right\} \right.} \right. \right) \right)}}\quad\&} \right.} \\ {\quad {\left( {\left\{ {1,0,0,0} \right\}\hat{}{\sim\left( {\left\{ {1,0,0,0} \right\} + \left\{ {1,1,0,0} \right\}} \right)}} \right)\quad\&}} \\ {\quad \left( {\left\{ {1,0,0,0} \right\}\hat{}{\sim\left( {\left\{ {1,1,1,0} \right\} + \left\{ {0,0,0,0} \right\}} \right)}} \right)} \\ {= \quad {\left\{ {0,0,0,1} \right\} \quad\&}} \\ {\quad {\left( {\left\{ {1,0,0,0} \right\}\hat{}{\sim\left\{ {1,0,1,0} \right\}}} \right)\quad\&}} \\ {\quad {\left( {\left\{ {1,0,0,0} \right\}\hat{}{\sim\left\{ {0,1,0,0} \right\}}} \right)\quad\&}} \\ {\quad \left( {\left\{ {1,0,0,0} \right\}\hat{}{\sim\left\{ {1,1,1,0} \right\}}} \right)} \\ {= \quad {\left\{ {0,0,0,1} \right\} \quad\&}} \\ {\quad {\left( {\left\{ {1,0,0,0} \right\}\hat{}\left\{ {0,1,0,1} \right\}} \right)\quad\&}} \\ {\quad {\left( {\left\{ {1,0,0,0} \right\}\hat{}\left\{ {1,0,1,1} \right\}} \right)\quad\&}} \\ {\quad \left( {\left\{ {1,0,0,0} \right\}\hat{}\left\{ {0,0,0,1} \right\}} \right)} \\ {= \quad {{{{{{{\left\{ {0,0,0,1} \right\} \quad\&}\quad \left\{ {1,1,0,1} \right\}}\quad\&}\quad \left\{ {0,0,1,1} \right\}}\quad\&}\quad \left\{ {1,0,0,1} \right\}} = {{\left\{ {0,0,0,1} \right\} \quad\&}\quad \left\{ {0,0,0,1} \right\}}}} \\ {{= \quad \left\{ {0,0,0,1} \right\}};} \end{matrix}\quad$

[0125] C=CC & M={1,0,0,0} & {0,0,0,1}={0,0,0,0};

[0126] i=i+1=1+1=2;

[0127] go to Step 2;

[0128] At this point, i=2, and so step 3 is repeated. After four iterations of step 3, one arrives at:

M={0,0,0,1};

C={0,0,0,0}.

[0129] So the low-order bit of x*y is known and equal to 0. The remaining bits are not known.

[0130] For x*y, the operand non-influence sets are:

N _(x)=0={0,0,0,0};

N _(y)0={0,0,0,0}.

[0131] This signifies that each bit in both operands is always relevant in operation mul.

[0132] 8. Algorithm for SHIFT LEFT LOGIC Operation

[0133]FIG. 7 is a schematic diagram depicting the relationship of x, y, M_(x), M_(y), C_(x), C_(y), M and C for a concrete example of an SHIFT LEFT LOGIC (SLL) operation. Note that the ones in M_(x) and M_(y) correspond to the location of know bit in the associated variable. The technique for calculating M and C from M_(x), M_(y), C_(x), and C_(y) will now be described.

[0134] The following psuedo code illustrates calculation of bit sets M, C from similar bit sets M_(x), C_(x), M_(y), C_(y) for operation x<<y:

[0135] Step 1:

[0136] N_(y)=˜(size of C in bits−1);

[0137] M_(y)=M_(y)|N_(y);

[0138] C_(y)=C_(y) & ˜N_(y);

[0139] M=˜(˜M_(x)<<C_(y));

[0140] C=C_(x)<<C_(y);

[0141] N_(x)=˜(˜N>>C_(y));

[0142] i=1;

[0143] If (˜M_(y)==0), go to Quit;

[0144] Step 2:

[0145] If i>=size of C in bits, go to Quit;

[0146] Step 3:

[0147] C0=C_(y)|M_(y) & i;

[0148] M=M & ˜(˜M_(x)<<C0) & ˜(C^ C_(x)<<C0);

[0149] i=i+1;

[0150] go to Step 2;

[0151] Quit:

[0152] C=C & M;

[0153] For the SLL operation, x<<y, the operand non-influence sets are:

N _(x)=0={0,0,0,0};

N _(y)=0={0,0,0,0}.

[0154] This signifies that each bit in both operands is always relevant in operation SLL.

[0155] Turning now to FIG. 7, the SLL operation is illutrated for x={0,0, x1, 0}, y={0,0 y1, 1} and N={0,0,0,0}, as on FIG. 8. Then M_(x)={1,1,0,1}, C_(x){0,0,0,0} and M_(y)={1,1,0,1}, C_(y)={0,0,0,1}. Then the steps of the psuedo code outlined above yield the following: Step 1:   N_(y) =  ∼ (4 − 1) =  ∼ 3 =  ∼ {0, 0, 1, 1} = {1, 1, 0, 0}   $M_{y} = {\left\{ {1,1,0,1} \right\} {{{{\left\{ {1,1,0,0} \right\} = \left\{ {1,1,0,1} \right\}};\quad {C_{y} = {{\left. {\left\{ {0,0,0,1} \right\}\&} \right.\sim\left( {1,1,0,0} \right)} = {{{\left\{ {0,0,0,1} \right\} \quad\&}\quad \left\{ {0,0,1,1} \right\}} = \left\{ {0,0,0,1} \right\}}}};\quad {{\begin{matrix} {M = {{\sim\left( {{\sim\left\{ {1,1,0,1} \right\}}\left\{ {0,0,0,1} \right\}} \right)} = {{\sim\left( {\left\{ {0,0,1,0} \right\} \left\{ {0,0,0,1} \right\}} \right)} = {\sim\left\{ {0,1,0,0} \right\}}}}} \\ {{= \left\{ {1,0,1,1} \right\}};} \end{matrix}\quad C} = {{\left\{ {0,0,0,0} \right\} \left\{ {0,0,0,1} \right\}} = \left\{ {0,0,0,0} \right\}}};\quad {{\begin{matrix} {N_{x} = {{\sim\left( {{\sim\left\{ {0,0,0,0} \right\}}\left\{ {0,0,0,1} \right\}} \right)} = {{\sim\left( {\left\{ {1,1,1,1} \right\} \left\{ {0,0,0,1} \right\}} \right)} = {\sim\left\{ {0,1,1,1} \right\}}}}} \\ {{= \left\{ {1,0,0,0} \right\}};} \end{matrix}\quad i} = 1};\quad {{if}\quad \left( {{\sim\left\{ {1,1,0,1} \right\}}0} \right)}},{{{go}\quad {to}\quad {Quit}};\quad {{{\text{Step 2:}\quad {If}\quad 1} >}\quad = 4}},{{{go}\quad {to}\quad {Quit}};\quad {{\text{Step 3:}\quad \begin{matrix} {C_{0} = {\left\{ {0,0,0,1} \right\} {{{{{\sim\left\{ {1,1,0,1} \right\}}\quad\&}\quad \left\{ {0,0,0,1} \right\}} = {\left\{ {0,0,0,1} \right\} {{{\left\{ {0,0,1,0} \right\} \quad\&}\quad \left\{ {0,0,0,1} \right\}}}}}}}} \\ {= {\left\{ {0,0,0,1} \right\} {{{\left\{ {0,0,0,0} \right\} = \left\{ {0,0,0,1} \right\}};}}}} \end{matrix}\quad \begin{matrix} {M = \quad {\left. {{\left. {\left\{ {1,0,1,1} \right\} \quad\&} \right.\sim\left( {{\sim\left\{ {1,1,0,1} \right\}}\left\{ {0,0,0,1} \right\}} \right)}\quad\&} \right.\sim\left( {{\left\{ {0,0,0,0} \right\}\hat{}\left\{ {0,0,0,0} \right\}}} \right.}} \\ {\quad \left. \left\{ {0,0,0,1} \right\} \right)} \\ {= \quad {\left. {{\left. {\left\{ {1,0,1,1} \right\} \quad\&} \right.\sim\left\{ {0,1,0,0} \right\}}\quad\&} \right.\sim\left( {\left\{ {0,0,0,0} \right\}\hat{}\left\{ {0,0,0,0} \right\}} \right)}} \\ {{= \quad {{\left. {{{\left\{ {1,0,1,1} \right\} \quad\&}\quad \left\{ {1,0,1,1} \right\}}\quad\&}\quad \right.\sim\left\{ {0,0,0,0} \right\}} = {{{\left\{ {1,0,1,1} \right\} \quad\&}\quad \left\{ {1,1,1,1} \right\}} = \left\{ {1,0,1,1} \right\}}}};} \end{matrix}\begin{matrix} {N_{x} = \quad {\sim{\left. \left( {{\sim\left\{ {1,0,0,0} \right\}}{{{\sim\left\{ {0,0,0,0} \right\}}\left\{ {0,0,0,1} \right\}}}} \right. \right) = {\sim\left( {\left\{ {0,1,1,1} \right\} {{\left\{ {1,1,1,1} \right\} }}} \right.}}}} \\ {{\quad \left. \left\{ {0,0,0,1} \right\} \right)} = {\sim\left( {{\left. {\left\{ {0,1,1,1} \right\} {\left\{ {0,1,1,1} \right\}}} \right) = {{\sim\left\{ {0,1,1,1} \right\}} = \left\{ {1,0,0,0} \right\}}};} \right.}} \end{matrix}\quad i} = {{i + 1} = {{1 + 1} = 2}}};\quad {{go}\quad {to}\quad {Step}\quad 2};\quad {{{\text{Step 2:}\quad {if}\quad 2} >}\quad = 4}},{{{go}\quad {to}\quad {Quit}};\quad {{\text{Step 3:}\quad \begin{matrix} {C_{0} = {\left\{ {0,0,0,1} \right\} {{{{{\sim\left\{ {1,1,0,1} \right\}}\quad\&}\quad \left\{ {0,0,1,0} \right\}} = {\left\{ {0,0,0,1} \right\} {{{\left\{ {0,0,1,0} \right\} \quad\&}\quad \left\{ {0,0,1,0} \right\}}}}}}}} \\ {{= \left\{ {0,0,1,1} \right\}};} \end{matrix}\quad \begin{matrix} {M = \quad {\left. {{\left. {\left\{ {1,0,1,1} \right\} \quad\&} \right.\sim\left( {{\sim\left\{ {1,1,0,1} \right\}}\left\{ {0,0,1,1} \right\}} \right)}\quad\&} \right.\sim\left( {{\left\{ {0,0,0,0} \right\}\hat{}\left\{ {0,0,0,0} \right\}}} \right.}} \\ {\quad \left. \left\{ {0,0,1,1} \right\} \right)} \\ {= \quad {\left. {{\left. {\left\{ {1,0,1,1} \right\} \quad\&} \right.\sim\left( {\left\{ {0,0,1,0} \right\} \left\{ {0,0,1,1} \right\}} \right)}\quad\&} \right.\sim\left( {\left\{ {0,0,0,0} \right\}\hat{}\left\{ {0,0,0,0} \right\}} \right)}} \\ {= \quad {\left. {{\left. {\left\{ {1,0,1,1} \right\} \quad\&} \right.\sim\left\{ {0,0,0,0} \right\}}\quad\&} \right.\sim\left\{ {0,0,0,0} \right\}}} \\ {{= \quad {{{{{\left. \left( {1,0,1,1} \right. \right\} \quad\&}\quad \left\{ {1,1,1,1} \right\}}\quad\&}\quad \left\{ {1,1,1,1} \right\}} = \left\{ {1,0,1,1} \right\}}};} \end{matrix}\quad \begin{matrix} {N_{x} = \quad {\sim{\left. \left( {{\sim\left\{ {1,0,0,0} \right\}}{{{\sim\left\{ {0,0,0,0} \right\}}\left\{ {0,0,1,1} \right\}}}} \right. \right) = {\sim\left( {\left\{ {0,1,1,1} \right\} {{\left\{ {1,1,1,1} \right\} }}} \right.}}}} \\ {{\quad \left. \left\{ {0,0,1,1} \right\} \right)} = {\sim\left( {{\left. {\left\{ {0,1,1,1} \right\} {\left\{ {0,0,0,1} \right\}}} \right) = {{\sim\left\{ {0,1,1,1} \right\}} = \left\{ {1,0,0,0} \right\}}};} \right.}} \end{matrix}\quad i} = {{2 + 1} = 3}};\quad {{go}\quad {to}\quad {Step}\quad 2};\quad {{{\text{Step 2:}\quad {If}\quad 3} >}\quad = 4}},{{{go}\quad {to}\quad {Quit}};\quad {{\text{Step 3:}\quad \begin{matrix} {C_{0} = {\left\{ {0,0,0,1} \right\} {{{{{\sim\left\{ {1,1,0,1} \right\}}\quad\&}\quad \left\{ {0,0,1,1} \right\}} = {\left\{ {0,0,0,1} \right\} {{{\left\{ {0,0,1,0} \right\} \quad\&}\quad \left\{ {0,0,1,1} \right\}}}}}}}} \\ {{= \left\{ {0,0,1,1} \right\}};} \end{matrix}\quad \begin{matrix} {M = \quad {\left. {{\left. {\left\{ {1,0,1,1} \right\} \quad\&} \right.\sim\left( {{\sim\left\{ {1,1,0,1} \right\}}\left\{ {0,0,1,1} \right\}} \right)}\quad\&} \right.\sim\left( {{\left\{ {0,0,0,0} \right\}\hat{}\left\{ {0,0,0,0} \right\}}} \right.}} \\ {\quad \left. \left\{ {0,0,1,1} \right\} \right)} \\ {= \quad {\left. {{\left. {\left\{ {1,0,1,1} \right\} \quad\&} \right.\sim\left( {\left\{ {0,0,1,0} \right\} \left\{ {0,0,1,1} \right\}} \right)}\quad\&} \right.\sim\left( {\left\{ {0,0,0,0} \right\}\hat{}\left\{ {0,0,0,0} \right\}} \right)}} \\ {= \quad {\left. {{\left. {\left\{ {1,0,1,1} \right\} \quad\&} \right.\sim\left\{ {0,0,0,0} \right\}}\quad\&} \right.\sim\left\{ {0,0,0,0} \right\}}} \\ {{= \quad {{{{{\left\{ {1,0,1,1} \right\} \quad\&}\quad \left\{ {1,1,1,1} \right\}}\quad\&}\quad \left\{ {1,1,1,1} \right\}} = \left\{ {1,0,1,1} \right\}}};} \end{matrix}\quad \begin{matrix} {N_{x} = \quad {\sim{\left. \left( {{\sim\left\{ {1,0,0,0} \right\}}{{{\sim\left\{ {0,0,0,0} \right\}}\left\{ {0,0,1,1} \right\}}}} \right. \right) = {\sim\left( {\left\{ {0,1,1,1} \right\} {{\left\{ {1,1,1,1} \right\} }}} \right.}}}} \\ {{\quad \left. \left\{ {0,0,1,1} \right\} \right)} = {\sim\left( {{\left. {\left\{ {0,1,1,1} \right\} {\left\{ {0,0,0,1} \right\}}} \right) = {{\sim\left\{ {0,1,1,1} \right\}} = \left\{ {1,0,0,0} \right\}}};} \right.}} \end{matrix}\quad i} = {{3 + 1} = 4}};\quad {{go}\quad {to}\quad {Step}\quad 2};\quad {{{\text{Step 2:}\quad {If}\quad 4} >}\quad = 4}},{{{go}\quad {to}\quad {Quit}};\quad {{\text{Quit:}\quad C} = {{{\left\{ {0,0,0,0} \right\} \quad\&}\quad \left\{ {1,0,1,1} \right\}} = \left\{ {0,0,0,0} \right\}}};}}\quad}}$

[0156] So the third bit of x−y is unknown. Other bits are known and equal to 0.

[0157] For x<<y, the operand non-influence sets are:

N _(x)={1,0,0,0};

N _(y)={1,1,0,0}.

[0158] This signifies that high bit of first operand and high two bits of second operand are always unrelevant in the operation SLL.

[0159] 9. Algorithm for SHIFTRIGHTLOGIC (SRL) Operation

[0160] The following algorithm can be used to calculate bit sets M, C from similar bit sets M_(x), C_(x), M_(y), C_(y) for the SRL operation, x>>y:

[0161] Step 1:

[0162] M_(y)=M_(y)|˜(size of C in bits−1);

[0163] C_(y)=C_(y) & (size of C in bits−1);

[0164] M=˜(˜M_(x)>>C_(y));

[0165] C=C_(x)>>C_(y);

[0166] i=1;

[0167] If (˜M_(y)==0), go to Quit;

[0168] Step 2:

[0169] If i>=size of C in bits, go to Quit;

[0170] Step 3:

[0171] C0=C_(y)|˜M_(y) & i;

[0172] M=M & ˜(˜M_(x)>>C0) & ˜(C^ C_(x)>>C0);

[0173] i=i+1;

[0174] go to Step 2;

[0175] Quit:

[0176] C=C & M.

[0177] For x>>y, the operand non-influence sets are:

N _(x)=0={0,0,0,0};

N _(y)=0={0,0,0,0}.

[0178] This signifies that each bit in both operands is always relevant in operation srl.

[0179] 10. Algorithm for SHIFTRIGHTARITHMETIC (SRA) Operation

[0180] The following pseudo code illustrates the calculation of bit sets M, C from similar bit sets M_(x), C_(x), M_(y), C_(y) for the arithmetic SRA operation (x>>y):

[0181] Step 1:

[0182] M_(y)=M_(y)|˜(size of C in bits−1);

[0183] C_(y)=C_(y) & (size of C in bits−1);

[0184] M=˜(˜M_(x)>>>C_(y));

[0185] C=C_(x)>>>C_(y);

[0186] i=1;

[0187] If (˜M_(y)==0), go to Quit;

[0188] Step 2:

[0189] If i>=size of C in bits, go to Quit;

[0190] Step 3:

[0191] C0=C_(y)|˜M_(y) & i;

[0192] M=M & ˜(˜M_(x)>>>C0) & ˜(C^ C_(x)>>>C0);

[0193] i=i+1;

[0194] go to Step 2;

[0195] Quit:

[0196] C=C & M

[0197] For x>>y, the operand non-influence sets are:

N _(x)=0={0,0,0,0};

N _(y)=0={0,0,0,0}.

[0198] This signifies that each bit in both operands is always relevant in operation sra.

[0199] 11. Other Operations

[0200] Bit sets (M, C) for other operations are calculated analogously.

[0201] Use of the Sets

[0202] The advantages of the above-described approach are many. The bit sets provided according to these algorithms can be used to simplify common equations such as (x|0xFFFF), so that the time required for the compiler optimization phase is reduced.

[0203] The method also allows simplification of complicated expressions. For example, using the sets M and C for an or operation, a compiler can simplify an expression involving the conditional operator, such as:

(x|y)>12?1:0

[0204] If, as before x={1, x2, x1, 0} and y={y3, 1, y1, 0}, it follows that, for operation (x|y), M={1,1,0,1} and C={1,1,0,0}. Thus, the value of (x|y) is either 12 or 14. (The value is 12 when the values of x1 and y1 are both 0, and 14 otherwise.) The conditional expression above can then be simplified to examining only the unknown bit of (x|y):

((x|y)>>1)&3

[0205] which requires only three very fast operations, i.e., binary or, binary right shift, and binary and. This simplification is made possible using the M, C, and N sets defined above.

[0206] In a preferred embodiment of the invention the above-described acts are performed by a CPU executing program code embodied in a computer readable medium. The medium may be magnetic or optical storage media, semiconductor memory, or electromagnetic signals encoding digital data.

[0207] The invention has now been described with reference to the preferred embodiments. Alternatives and substitutions will now be apparent to persons of skill in the art. In particular, the particular logical values assigned to the bit sets may be varied. Also, the principles of the invention can be extended to other operations in the manner described above. Accordingly, it is not intended to limit the invention except as provided by the appended claims. 

What is claimed is:
 1. A method, performed by a compiler executing on a CPU, for constant bit folding an expression having a result determined by binary operations on a plurality of operands in the form of integer bit sets, with each bit set having either a constant or a non-constant in each bit position of the bit set, said method comprising the acts of: for each operand, forming an operand known-bit set having a first value in bit positions where a corresponding bit position in an associated operand has a constant value and with the known-bit set having a second value in bit positions where a corresponding bit position in the associated operand has a non-constant value; for each operand, forming an operand value bit set having bit values, in bit positions corresponding to bit positions in the known-bit set equal to the first value, having a constant value equal to the corresponding bit values in the associated operand; logically processing the operand known-bit sets and operand value bit sets for all operands to form a result known-bit set, having a first value for bit positions corresponding to bit positions in the result having constant values; and forming a result value bit set having bit values, in bit positions corresponding the bit positions having the first value in said result known-bit set, equal constant values of the result bit set at those values.
 2. The method of claim 1 where said step of logical processing further comprises the acts of: performing selected logical operations, correlated to operations in the expression, on the bits of said operand known-bit sets and operand value bit sets.
 3. The method of claim 1 further comprising the steps of: performing selected logical operations, correlated to operations in the expression, on the operand known-bit sets and operand value bit sets to obtain a non-influence bit set for a first operand having a first value at bit positions of the first operand that have no influence on the values of bit positions of the result.
 4. The method of claim 2 where the expression has a result equal to the binary not (˜) operation of a first operand (x), with the operand known-bit set represented by M_(x) and the operand value bit set represented by C_(x), said method comprising the steps of: setting the result known-bit set, M, equal to M_(x); and setting the result value bit set, C, equal to C=˜C_(x) & M.
 5. The method of claim 2 where the expression has a result equal to the binary or (|) operation of a first operand (x) and a second operand (y), with the operand known-bit sets represented by M_(x) and M_(y) and the operand value bit sets represented by C_(x) and C_(y), said method comprising the steps of: setting the result value bit set, C, equal to C_(x)|C_(y); and setting the result known-bit set, M, equal to M_(x) & M_(y)|C.
 6. The method of claim 5 further comprising the step of: setting the first operand non-influence bit set equal to N_(x) equal to C_(y)|N, and setting the second operand non-influence bit set, N_(y), equal to C_(x)|N, where N={0,0,0,0}.
 7. The method of claim 2 where the expression has a result equal to the binary and (&) operation of a first operand (x) and a second operand (y), with the operand known-bit sets represented by M_(x) and M_(y) and the operand value bit sets represented by C_(x) and C_(y), said method comprising the steps of: setting the result known-bit set, M, equal to M_(x) & M_(y)|M_(x) & ˜C_(x)|M_(y) & ˜C_(y); and setting the result value bit set, C, equal to C_(x) & C_(y).
 8. The method of claim 7 further comprising the step of: setting the first operand non-influence bit set equal to N_(x) equal to ˜(M_(y) & ˜C_(y))|N, and setting the second operand non-influence bit set, N_(y), equal to ˜(M_(x) & ˜C_(x))|N where N={0,0,0,0}.
 9. The method of claim 2 where the expression has a result equal to the binary xor (^ ) operation of a first operand (x) and a second operand (y), with the operand known-bit sets represented by M_(x) and M_(y) and the operand value bit sets represented by C_(x) and C_(y), said method comprising the steps of: setting the result known-bit set, M, equal to M_(x) & M_(y); and setting the result value bit set, C, equal to (C_(x)^ C_(y)) & M.
 10. The method of claim 2 where the expression has a result equal to the binary addition (+) operation of a first operand (x) and a second operand (y), with the operand known-bit sets represented by M_(x) and M_(y) and the operand value bit sets represented by C_(x) and C_(y), said method comprising the steps of: setting the result value bit set, C, equal to C_(x)+C_(y); setting the result-known bit set, M, equal to M_(x) & M_(y) & (C^ ˜((C_(x)|˜M_(x))+(C_(y)|˜M_(y)))) & (C^ ˜(C_(x)+(C_(y)|˜M_(y)))) & (C^ ˜((C_(x)|˜M_(x))+C_(y))); and resetting the result value bit set, C, equal to C & M.
 11. The method of claim 2 where the expression has a result equal to the binary subtraction (−) operation of a first operand (x) and a second operand (y), with operand known-bit sets represented by M_(x) and M_(y) and the operand value bit sets represented by C_(x) and C_(y), said method comprising the steps of: setting the result value bit set, C, equal to C_(x)—C_(y); setting the result known bit set, M, equal to M_(x) & M_(y) & (C^ ˜((C_(x)|˜M_(x))−(C_(y)|˜M_(y)))) & (C^ ˜(C_(x)−(C_(y)|˜M_(y)))) & (C^ ˜((C_(x)|M_(x))−C_(y))); and resetting the result value bit set, C, equal to C & M.
 12. The method of claim 2 where the expression has a result equal to the binary multiplication (x) operation of a first operand (x) and a second operand (y), with the operand known-bit sets represented by M_(x) and M_(y) and the operand value bit sets represented by C_(x) and C_(y), said method comprising the steps of: setting the result value bit set, M, equal to −(M_(y) & 1); setting the result value bit set, C, equal to −(C_(y)& 1); setting the result known bit set, M, equal to M=M_(x) & M|M_(x) & ˜C_(x)|M_(y) & ˜C; resetting the result value bit set, C, equal to C & C_(x); setting an iteration counter, i, equal to 1; and repeating the following sequence of steps, until the value of the iteration counter, i, equals the size of the result value bit set, C, in bits: resetting M_(x)=M_(x)<<1; resetting M_(x)=M_(x)|1; resetting C_(x)=C_(x)<<1; resetting M_(y)=M_(y)>>1; resetting C_(y)=C_(y)>>1; setting a first internal variable M_(yy)=−(M_(yy) & 1); setting a second internal variable C_(yy)=−(C_(y) & 1); setting a first internal variable M_(y)y=M_(x) & M_(y)y|M_(x) & ˜C_(x)|M_(y)y & ˜C_(y)y; setting C_(y)y=C_(y)y & C_(x); setting a third internal variable CC=C+C_(y)y; setting M=M & M_(y)y & (CC^ ˜((C|˜M)+(C_(y)y|˜M_(y)y))) & (CC^ ˜(C+(C_(y)y|˜M_(y)y))) & (CC^ ˜((C|˜M)+C_(y)y)); setting C=CC & M; and increasing the value of iteration counter, i, by
 1. 13. A computer program product comprising: a computer readable medium embodying program code therein for, when executed by a processor, causing a computer to constant bit fold an expression having a result determined by binary operations on a plurality of operands in the form of integer bit sets, with each bit set having either a constant or a non-constant in each bit position of the bit set, said program code comprising: for each operand, program code for forming an operand known-bit set having a first value in bit positions where a corresponding bit position in an associated operand has a constant value and with the known-bit set having a second value in bit positions where a corresponding bit position in the associated operand has a non-constant value; for each operand, program code for forming an operand value bit set having bit values, in bit positions corresponding to bit positions in the known-bit set equal to the first value, having a constant value equal to the corresponding bit values in the associated operand; program code for logically processing the operand known-bit sets and operand value bit sets for all operands to form a result known-bit set, having a first value for bit positions corresponding to bit positions in the result having constant values; and program code for forming a result value bit set having bit values, in bit positions corresponding the bit positions having the first value in said result known-bit set, equal constant values of the result bit set at those values.
 14. The computer program product of claim 13 further comprising: computer program code for performing selected logical operations, correlated to operations in the expression, on the bits of said operand known-bit sets and operand value bit sets. 